//
//  LPVersion.m
//  彩票
//
//  Created by liupan on 2016/12/6.
//  Copyright © 2016年 liupan. All rights reserved.
//

#import "LPVersion.h"
#import "LPNewFeatureController.h"
#import "LPTabBarController.h"
#import "LPSaveTool.h"
#define LPVersionKey @"version"

@implementation LPVersion
//根据版本设置根控制器
+ (UIViewController *)rootViewController{

    //获取当前版本号
    NSString *curVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
    //获取上一个版本号
    NSString *lastVersion = [LPSaveTool objectForKey:LPVersionKey];
    UIViewController *RootVC = nil;
    if ([curVersion isEqualToString:lastVersion]) {//没有最新的版本，进入主页面
        RootVC = [[LPTabBarController alloc]init];
    }else{//有新版本，进入新特性
        RootVC = [[LPNewFeatureController alloc]init];
        //存储当前版本号
        [LPSaveTool setObject:curVersion forKey:LPVersionKey];
    }
    return RootVC;
}
@end
